use "$data/demog_meta.dta", clear

*drop top outliers
egen p999=pctile(loan_amount), p(99.9)
drop if rate_spread>p999

gen above=.
replace above=0 if rate_spread<5.75&rate_spread>5&loan_amount>=50
replace above=1 if rate_spread>=5.75&rate_spread<12&loan_amount>=50

binscatter rate_spread as_of if as_of>=2010, by(above) line(connect) xline(2014) ytitle(Interest Rate Spread) xtitle(Year)/*
*/ legend(label(1 "Rate Spread 5 to 5.75") label(2 "Rate Spread>5.75")) yscale(r(5 8)) ylabel(5(1)8)
graph export "$figures/interest_over_time_high_capped.eps", as(eps) preview(on) replace


gen above_50=.
replace above_50=0 if rate_spread<7.75&rate_spread>7&loan_amount<50
replace above_50=1 if rate_spread>=7.75&loan_amount<50&rate_spread<12

binscatter rate_spread as_of if as_of>=2010, by(above_50) line(connect) xline(2014) ytitle(Interest Rate Spread) xtitle(Year)/*
*/ legend(label(1 "Rate Spread 7 to 7.75") label(2 "Rate Spread>7.75")) ylabel(7(1)10) yscale(r(7 10))
graph export "$figures/interest_over_time_low_capped.eps", as(eps) preview(on) replace

